

Vue.component2('a_1_0_3_4_0_img', {  
    template: `
    <div >
    <div class="a_1_0_3_4_0_container">  
        <div class="a_1_0_3_4_0_image_wrapper">  
            <img :src="data.show_imgsrc" alt="Image">  
        </div>  
        <div class="a_1_0_3_4_0_span_wrapper">  
            <span>{{data.name}}</span>  
        </div>  
        <div class="a_1_0_3_4_0_span_wrapper">
            
                <div  @click="click1($event,k)" v-for="(v,k) in data.icon_data"
                :key="k">
                <a_1_0_3_0_0 style="display: inline-block;"
                :deepcopy_data="v"></a_1_0_3_0_0>
                </div>
        </div>  
    </div>


<div :key="refresh">
    <el-dialog
    class="a_1_0_3_4_0_tabledialog"
  title="参与者列表"
  :visible.sync="dialogVisible"
  width="30%"
  >
<el-table
:data="data.tableData"
style="width: 100%"
max-height="250">
<el-table-column fixed prop="id" label="参与者id" width="110"></el-table-column>
<el-table-column prop="name" label="参与者名称" width="110"></el-table-column>
<el-table-column fixed="right" label="操作"width="110">
  <template slot-scope="scope">
    <el-button
      @click.native.prevent="del_other_project(scope.$index, data.tableData)"
      type="text"
      size="small">
      移除
    </el-button>
  </template>
</el-table-column>
</el-table>
  <span slot="footer" class="dialog-footer">
    <el-button @click="adddd = '1'">添加</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog>

</div>
<input type="file" ref="change_img" style="display: none;">
    </div>
`,  
  data() {
      return {
        dialogVisible:false,
        change_img:false,
        add_show_flag:false,
        adddd:'0',
        refresh:"1",
        data:{
            tableData:[
                {"id":1,"name":"王五",},
                {"id":2,"name":"王五",},
            ],
            icon_data:{},
            test:false,
            show_imgsrc:"",
            show_text1:"",
            show_text2:"",
        }
      };
  },
  watch:{
    'adddd':function(e){

        this.adddd='0';
        this.$prompt('添加别人参与我的项目', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
          }).then(({ value }) => {
           this.data.添加别人参与我的项目(value);
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '取消输入'
            });    
          });


    }
  },
  methods:{
    handleAvatarSuccess(){},
    beforeUpload(file) {  
      const formData = new FormData();  
      formData.append('file', file);  
      formData.append('id', '1');  
      formData.append('id2', '2');  
  
      axios.post('http://localhost:8888/upload', formData, {  
        headers: {  
          'Content-Type': 'multipart/form-data'  
        }  
      }).then(response => {  
        console.log('Upload successful:', response.data);  
        // 根据需要更新 fileList 或执行其他操作  
      }).catch(error => {  
        console.error('Upload failed:', error);  
      });  
  
      // 阻止自动上传  
      return false;  
    }  ,
    del_other_project:function(del_idx,data){

        this.$confirm('删除别人参与我的项目', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            let other_id=data[del_idx].id;
           this.data.删除别人参与我的项目(other_id,del_idx);
          
          }).catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            });          
          });

    },
    click1:async function(event,k){
       /* console.log(',,,',this.data.icon_data[k].click)*/
        lhp_run_func(this.data.icon_data[k].click);
        if(!this.data.click_stop){event.stopPropagation();}//阻止父级

    },
    refresh_func:function(e){
        this.refresh=this.refresh=="2"?"1":"2";
    },
    handleMouseEnter() {  
        if(this.hover_flag==false){
            this.hover_flag=true; 
            this.style2=this.style2+`color:${this.data.hovercolor};`;
        }
      },  
      handleMouseLeave() {  
        if(this.hover_flag==true){
            this.hover_flag=false; 
            let style2="";
            for (let key in this.style){
                style2=style2+`${key}:${this.style[key]};`
            }
            this.style2=style2;
        }
      } ,
    setstyle2:function(name,value){
        this.style[name]=value;
        let style2="";
        for (let key in this.style){
            style2=style2+`${key}:${this.style[key]};`
        }
        this.style2=style2;
    },
    handleclick:function(){
try{this.data.click()}
catch{}
    }
  },
  mounted:function(){
    if(_this.deepcopy_data.test==true){
        _this.data.show_imgsrc="python.png";
        _this.data.show_text2="文本显示框(a0)";

    }
    
console.log("44444",_this.deepcopy_data)
    let urls=_this.deepcopy_data.urls;
_this.data.删除我的项目_request=request______({method:'post',url:urls.删除我的项目_url});

_this.data.删除我的项目_recv=function(received_data){
    _this.data.callback_data.删除成功回调(received_data);
    // console.log("接收数据",received_data);
    // _this.data.tree_data.del_path(_this.data.path);
    // // _this.data.tree_data.set_dict(received_data,_this.data.path);
    _this.data.删除我的项目_flag=true;
}
_this.data.删除我的项目=async function(){
    console.log("开始删除我的项目_url",_this.data)
    let count=0;
    _this.data.删除我的项目_flag=false;
    _this.data.删除我的项目_request({
        body_data:{dir1_id:_this.data.dir1_id,user_id:_this.data.user_id,num:_this.data.num},
        execute_lst:[
                      {
                        'type':'func',
                        'func':_this.data.删除我的项目_recv,
                        'args':['received_data'],
                      },
                    ]
    });
    await time_sleep(20);
    while(1){
        count++;
        await time_sleep(1);
        if(_this.data.删除我的项目_flag==true){break}
        if(count>500){Vue.prototype.$notify({type: 'error',message: '删除我的项目失败'});break}
    }
}

_this.data.删除别人参与我的项目_request=request______({method:'post',url:urls.删除别人参与我的项目_url});

_this.data.删除别人参与我的项目_recv=function(received_data){
    let del_idx=received_data.del_idx;
    _this.data.tableData.splice(del_idx, 1);
    // console.log("接收数据",received_data);
    // _this.data.tree_data.del_path(_this.data.path);
    // _this.data.tree_data.set_dict(received_data,_this.data.path);
    _this.data.删除别人参与我的项目_flag=true;
    _this.refresh_func();
}
_this.data.删除别人参与我的项目=async function(other_id,del_idx){
    let count=0;
    _this.data.删除别人参与我的项目_flag=false;
    _this.data.删除别人参与我的项目_request({
        body_data:{dir1_id:_this.data.dir1_id,user_id:_this.data.user_id,num:_this.data.num,other_id:other_id,del_idx:del_idx},
        execute_lst:[
                      {
                        'type':'func',
                        'func':_this.data.删除别人参与我的项目_recv,
                        'args':['received_data'],
                      },
                    ]
    });
    await time_sleep(20);
    while(1){
        count++;
        await time_sleep(1);
        if(_this.data.删除别人参与我的项目_flag==true){break}
        if(count>500){Vue.prototype.$notify({type: 'error',message: '删除别人参与我的项目失败'});break}
    }
}
_this.data.修改我的项目名称_request=request______({method:'post',url:urls.修改我的项目名称_url});

_this.data.修改我的项目名称_recv=function(received_data){
    _this.data.callback_data.修改我的项目名称成功回调(received_data);
    // console.log("接收数据",received_data);
    // _this.data.tree_data.del_path(_this.data.path);
    // // _this.data.tree_data.set_dict(received_data,_this.data.path);
    _this.data.修改我的项目名称_flag=true;
}
_this.data.修改我的项目名称=async function(val){
    console.log("开始删除我的项目_url",_this.data)
    let count=0;
    _this.data.修改我的项目名称_flag=false;
    _this.data.修改我的项目名称_request({
        body_data:{dir1_id:_this.data.dir1_id,user_id:_this.data.user_id,num:_this.data.num,name:val},
        execute_lst:[
                      {
                        'type':'func',
                        'func':_this.data.修改我的项目名称_recv,
                        'args':['received_data'],
                      },
                    ]
    });
    await time_sleep(20);
    while(1){
        count++;
        await time_sleep(1);
        if(_this.data.修改我的项目名称_flag==true){break}
        if(count>500){Vue.prototype.$notify({type: 'error',message: '修改我的项目名称失败'});break}
    }
}



_this.data.添加别人参与我的项目_request=request______({method:'post',url:urls.添加别人参与我的项目_url});

_this.data.添加别人参与我的项目_recv=function(received_data){
    console.log("添加别人参与我的项目_recv received_data",received_data)
    received_data.data.id=received_data.data.user_id;
    _this.data.tableData.push(received_data.data);
    // _this.data.callback_data.添加别人参与我的项目成功回调(received_data);
    // console.log("接收数据",received_data);
    // _this.data.tree_data.del_path(_this.data.path);
    // // _this.data.tree_data.set_dict(received_data,_this.data.path);
    _this.data.添加别人参与我的项目_flag=true;
    _this.refresh_func();
}
_this.data.添加别人参与我的项目=async function(val){
    console.log("开始删除我的项目_url",_this.data)
    let count=0;
    _this.data.添加别人参与我的项目_flag=false;
    _this.data.添加别人参与我的项目_request({
        body_data:{dir1_id:_this.data.dir1_id,user_id:_this.data.user_id,num:_this.data.num,other_id:val},
        execute_lst:[
                      {
                        'type':'func',
                        'func':_this.data.添加别人参与我的项目_recv,
                        'args':['received_data'],
                      },
                    ]
    });
    await time_sleep(20);
    while(1){
        count++;
        await time_sleep(1);
        if(_this.data.添加别人参与我的项目_flag==true){break}
        if(count>500){Vue.prototype.$notify({type: 'error',message: '添加别人参与我的项目失败'});break}
    }
}

_this.data.查看项目参与者目录_request=request______({method:'post',url:urls.查看项目参与者目录_url});

_this.data.查看项目参与者目录_recv=function(received_data){
    // console.log("查看项目参与者目录received_data",received_data)
    let project_user=received_data.project_user;

    _this.data.tableData=project_user;
    // _this.data.callback_data.查看项目参与者目录(received_data);
    // console.log("接收数据",received_data);
    // _this.data.tree_data.del_path(_this.data.path);
    // // _this.data.tree_data.set_dict(received_data,_this.data.path);
    _this.data.查看项目参与者目录_flag=true;
    
    _this.dialogVisible=true;
    _this.refresh_func();
}
_this.data.查看项目参与者目录=async function(){
    let count=0;
    _this.data.查看项目参与者目录_flag=false;
    _this.data.查看项目参与者目录_request({
        body_data:{dir1_id:_this.data.dir1_id,user_id:_this.data.user_id,num:_this.data.num},
        execute_lst:[
                      {
                        'type':'func',
                        'func':_this.data.查看项目参与者目录_recv,
                        'args':['received_data'],
                      },
                    ]
    });
    await time_sleep(20);
    while(1){
        count++;
        await time_sleep(1);
        if(_this.data.查看项目参与者目录_flag==true){break}
        if(count>500){Vue.prototype.$notify({type: 'error',message: '查看项目参与者目录失败'});break}
    }
}


_this.data.修改展示图片_recv=function(received_data){
  _this.data.callback_data.修改展示图片成功回调(received_data);
    _this.data.修改展示图片_flag=true;
    
    _this.refresh_func();
}
_this.data.修改展示图片=async function(file){
  let formData = new FormData();  
  formData.append('file', file);  
  formData.append('dir1_id', _this.data.dir1_id);  
  formData.append('user_id', _this.data.user_id);  
  formData.append('num', _this.data.num);  
  let protocol = window.location.protocol;  
  _this.data.修改展示图片_flag=false;
// 获取当前页面的主机名（例如：localhost 或 www.example.com）  
let hostname = window.location.hostname;  
// 获取当前页面的端口号（如果没有指定端口，则返回空字符串）  
let port = window.location.port ? `:${window.location.port}` : '';  
// 拼接新的 URL  
let newUrl = `${protocol}//${hostname}${port}${urls.修改展示图片_url}`;  

fetch(newUrl, {  
  method: 'POST', // 指定请求方法为 POST  
  body: formData, // 直接将 FormData 对象作为请求体  
})  
.then(response => {  

    // 检查响应状态
    if (!response.ok) {
      
    _this.$notify({
      message: '更新图片失败',
      type: 'error'
    }); 
      throw new Error(`HTTP error! status: ${response.status}`);
  }
  // 解析响应的 JSON 数据
  return response.json();
     
})  
.then(data => {  
  _this.data.修改展示图片_recv(data); 
})  
.catch(error => {  
  _this.$notify({
    message: '更新图片失败'+error,
    type: 'error'
  }); 
});
let count=0;


    await time_sleep(20);
    while(1){
        count++;
        await time_sleep(1);
        if(_this.data.修改展示图片_flag==true){break}
        if(count>500){Vue.prototype.$notify({type: 'error',message: '修改展示图片失败'});break}
    }
}
































let new_icon_data={
  // 99:{

  // icon_class:"icon iconfont icon-qianduan",
  // hovertext:"预览",
  // add_show:false,
  // click:async function(){
    
  //   window.location.href = 'http://39.106.34.123:8000/';
  //     // window.location.href = '/home?user_id='+_this.data.user_id+"&project_dir="+_this.data.dir1_id+"&project_id="+_this.data.num;
      
      
  //     },
  // },
  
  100:{

  icon_class:"icon iconfont icon-shezhi",
  hovertext:"编辑",
  add_show:false,
  click:async function(){
      window.location.href = '/home?user_id='+_this.data.user_id+"&project_dir="+_this.data.dir1_id+"&project_id="+_this.data.num;
      
      
      },
  },

}
if (cookie_read("easyedit_userid")==_this.deepcopy_data.user_id){
 lhp_deepcopy1(new_icon_data,{

    
  198:{

    icon_class:"icon iconfont icon-shanchu",
    hovertext:"删除",
    add_show:false,
    click:async function(){
        
        _this.$confirm('此操作将永久删除, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
        _this.data.删除我的项目();
          
          }).catch(() => {
            _this.$message({
              type: 'info',
              message: '已取消删除'
            });          
          });
        
        },
    },
    199:{

    icon_class:"icon iconfont icon-write",
    hovertext:"修改项目名称",
    add_show:false,
    click:async function(){
        _this.$prompt('修改目录名称', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
          }).then(({ value }) => {
           _this.data.修改我的项目名称(value);
          }).catch(() => {
            _this.$message({
              type: 'info',
              message: '取消输入'
            });       
          });
        
        },
    },
    296:{

    icon_class:"icon iconfont icon-yonghu",
    hovertext:"项目参与者名单",
    add_show:false,
    click:async function(){
        _this.data.查看项目参与者目录();
        },
    },
    297:{

    icon_class:"icon iconfont icon-xiugaitupian",
    hovertext:"修改图片",
    add_show:false,
    add_show:false,
    click:async function(){
      if(!_this.change_img_init){
        _this.change_img_init=true;

    _this.$refs.change_img.addEventListener('change', () => { 
      // 获取所选文件的 File 对象  
    let file = _this.$refs.change_img.files[0];  
  
    // 检查文件是否存在  
    if (!file) {  
        console.log('没有选择文件。');  
        return;  
    }  
  
    // 获取文件的名称和类型  
    let fileName = file.name;  
    let fileType = file.type;  
  
    // 检查文件名是否以 .jpg 结尾（不区分大小写）  
    let isJPGByName = fileName.toLowerCase().endsWith('.png');  
    


    // 检查文件的 MIME 类型是否为 image/png  
    let isPNGByType = fileType === 'image/png';
  
    // 如果文件名和类型都不匹配 .jpg，则打印消息  
    if (!isJPGByName || !isPNGByType) {  
     
      _this.$notify({
        message: '上传失败,后缀不是png',
        type: 'error'
      });
    } else {  
      _this.data.修改展示图片(_this.$refs.change_img.files[0]);
    }  
  

      
  });  

      }
      _this.$refs.change_img.click();  
        },
    },
 })
}
_this.data.icon_data=new_icon_data;
} }
);

Vue.component2('a_1_0_3_4_0', {  
  template: `
  <div class="a_1_0_3_4_0_father_container" v-show="data.show_flag">  
  <div class="a_1_0_3_4_0_title">
  <div style="padding-left:20px;color:#bcbcbc">项目列表
  
      <div style="display:inline-block;flex:1;">
      <div style="display:flex;
  justify-content: flex-end;
  display: flex;">
  
  </div>
  </div>
  </div>
  </div>
      <div class="row a_1_0_3_4_0_row"style="margin:0;padding:10px;":key="refresh">
          <a_1_0_3_4_0_img class="col-sm-4 col-md-3 col-lg-2 col-6"v-for="(item,indexr) in data.lst" :key="indexr":deepcopy_data="item">
          
          </a_1_0_3_4_0_img>
      </div>
  <div class="a_1_0_3_4_0_page">

  </div>
  </div>
`,  
data() {
    return {
      num:18,//一页显示10张图片
      total:0,
      now_select_page:0,
      false:false,
      true:true,
      refresh:"1",
      data:{
          show_flag:true,
          test:false,
          lst:[],
          url:'',//请求的url
          request:'',
      }
    };
},
watch:{
  'data.url':function(e){
      this.data.request=request______({method:'post',url:e});
      this.get_info({"page":0});
  }
},
methods:{
  refresh_func:function(e){
      this.refresh=this.refresh=="2"?"1":"2";
  },
  get_info2:function(){this.get_info({page:this.now_select_page})},
  //选择分页
  handleCurrentChange:function(page){
      this.now_select_page=page;
      this.get_info({
          page:page
      })
  },
},
mounted:function(){
  randonstr=function (length) {  
    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';  
    let result = '';  
    const charactersLength = characters.length;  
    for (let i = 0; i < length; i++) {  
        result += characters.charAt(Math.floor(Math.random() * charactersLength));  
    }  
    return result;  
  }  
  _this.callback_data={};
  _this.callback_data.删除成功回调=function(received_data){
      let num=received_data.num;
      for (let i=0;i<_this.data.lst.length;i++){
          if (_this.data.lst[i].num==num){
              _this.data.lst.splice(i, 1);  
              break
          }
      }
      _this.refresh_func();
  }
  _this.callback_data.修改我的项目名称成功回调=function(received_data ){
      let num=received_data.num;
      let name=received_data.name;
      for (let i=0;i<_this.data.lst.length;i++){
          if (_this.data.lst[i].num==num){
              _this.data.lst[i].name=name;
              break
          }
      }
      _this.refresh_func();

  }
  _this.callback_data.修改展示图片成功回调=function(received_data){
    let num=received_data.num;
    for (let i=0;i<_this.data.lst.length;i++){
        if (_this.data.lst[i].num==num){
          _this.data.lst[i]['show_imgsrc']=get_src(_this.data.lst[i]);
            break
        }
    }
    _this.refresh_func();

  }
  let urls=_this.deepcopy_data.urls;
  let get_src=function(obj){
    console.log("########obj",JSON.parse(JSON.stringify(obj)));
        let protocol = window.location.protocol;  
      // 获取当前页面的主机名（例如：localhost 或 www.example.com）  
      let hostname = window.location.hostname;  
      // 获取当前页面的端口号（如果没有指定端口，则返回空字符串）  
      let port = window.location.port ? `:${window.location.port}` : '';  
      // 拼接新的 URL  
      let newUrl = `${protocol}//${hostname}${port}${urls.获取图片_url}/${randonstr(20)}?user_id=${obj.user_id}&dir1_id=${obj.dir1_id}&num=${obj.num}`; 
            return newUrl
  }
  _this.data.添加新项目=function(obj){
      console.log("添加新项目:",obj);
      obj['show_imgsrc']=get_src(obj);
      obj['other_lst']=obj.other_lst;
      obj['show_text2']=obj.name;
      obj['callback_data']=_this.callback_data;
      obj.urls=urls;
      _this.data.lst.push(obj);
      _this.refresh_func();
  }
  _this.data.设置显示项目=function(obj){
      // {
      //     "user_id":'..'
      //     "dir1_id":'xx',//目录id
      //     "get_my_project_all": [
      //         {
      //             "name": "发",
      //             "other_lst": [
      //                 "2"
      //             ],
      //             "last_time": 1729244346.0308459,
      //             "num": 1
      //         }
      //     ]
      // }
      let new_lst=[];
      let data=obj.project_all;
      console.log("设置显示项目:",obj);
      console.log("datalst",data,data.length)
      for (let i=0;i<data.length;i++){
          let item=data[i];
          item['dir1_id']=obj.dir1_id;
          item['user_id']=obj.user_id;
          item['show_imgsrc']=get_src(item);
          item['other_lst']=obj.other_lst;
          item['show_text2']=obj.name;
          item['callback_data']=_this.callback_data;
          item.urls=urls;
          new_lst.push(item);
      }
      console.log("new_lst:",new_lst)
      _this.data.lst=new_lst;

      _this.refresh_func();
  }
} }
);